package cn.scau.server.service.iterator;

import cn.scau.server.service.Component;

import java.util.List;

public class ComponentIterator implements Iterator{
    private List<Component> list;
    private int currentIndex;

    public ComponentIterator(List<Component> list) {
        this.list = list;
        this.currentIndex = 0;
    }

    @Override
    public boolean hasNext() {
        return currentIndex < list.size();
    }

    @Override
    public Component next() {
        if (hasNext()) {
            return list.get(currentIndex++);
        }
        return null;
    }
}
